package data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.*;

/**
 *
 * @author Michal Hanzlik, Tomas Jiran
 */
/*
 create table Zanr (
 id_zanru             INT4                 not null,
 nazev_zanru          CHAR(32)             not null,
 charakteristika      VARCHAR(1024)        null,
 constraint PK_ZANR primary key (id_zanru)
 );
 */
@Entity
@Table(name = "zanr")
public class Zanr implements Serializable {

    /**
     * id_zanru INT4 not null
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "zanr_id_zanru_seq")    
    @Column(unique=true, nullable = false)
    private final int id_zanru;

    public int getId_zanru() {
        return id_zanru;
    }

    /**
     * nazev_zanru CHAR(32) not null
     */
    @Column(nullable = false)
    private String nazev_zanru;

    /**
     * charakteristika VARCHAR(1024) null
     */
    @Column(columnDefinition = "varchar(256)")
    private String charakteristika;
    
    @ManyToMany(mappedBy = "zanry")
    private List<Film> filmy;

    public Zanr() {
        id_zanru = 0;     
        filmy = new ArrayList<>();
    }

    public Zanr(int ID, String nazev_zanru) {
        this.id_zanru = ID;
        this.nazev_zanru = nazev_zanru;
    }
    
    @Override
    public String toString() {
        return nazev_zanru;
    }
    
    public int getID() {
        return id_zanru;
    }

    public String getNazev_zanru() {
        return nazev_zanru;
    }
    
    public void setNazev_zanru(String nazev_zanru) {
        this.nazev_zanru = nazev_zanru;
    }

    public String getCharakteristika() {
        return charakteristika;
    }

    public void setCharakteristika(String charakteristika) {
        this.charakteristika = charakteristika;
    }

    public int getId_zanr() {
        return id_zanru;
    }

    public List<Film> getFilmy() {
        return filmy;
    }

    public void setFilmy(List<Film> filmy) {
        this.filmy = filmy;
    }
}